package com.example.datn.activities;

import android.app.Activity;
import android.content.Intent;
import android.database.Cursor;
import android.os.Bundle;
import android.support.v4.widget.SimpleCursorAdapter;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.widget.Adapter;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ListView;
import android.widget.TextView;



import com.example.datn.R;
import com.example.datn.favorite.MyDataHelper;
import com.example.datn.googleSearchAPIadapter.GoogleImageBean;

public class FavoriteNewActivity extends Activity{

	ListView lv;
	
	private Cursor cursor;
	
	
	private MyDataHelper data;
	private SimpleCursorAdapter adapter;
	
@Override
protected void onCreate(Bundle savedInstanceState) {
	// TODO Auto-generated method stub
	super.onCreate(savedInstanceState);
	setContentView(R.layout.favoritenew);

	lv=(ListView)findViewById(R.id.lvShow);
	
	data=new MyDataHelper(FavoriteNewActivity.this);
	cursor=data.selectAll();
	adapter=new SimpleCursorAdapter(FavoriteNewActivity.this, R.layout.favorite_item_list, cursor,
			new String[]{"_id","Title","Link"},
			new int[]{R.id.tvID,R.id.tvTitle,R.id.tvLink});	
		
	
	lv.setAdapter(adapter);
	lv.setOnItemClickListener(new OnItemClickListener() {

		@Override
		public void onItemClick(AdapterView<?> parent, View view, int position,
				long id) {
			Intent intent = new Intent(FavoriteNewActivity.this,WebTinTucActivity.class);
			
		String links=(String)((TextView)view.findViewById(R.id.tvLink)).getText();
		String title=(String)((TextView)view.findViewById(R.id.tvTitle)).getText();
			intent.putExtra("LINK", links);
			intent.putExtra("TITLE", title);
			
		startActivity(intent);
			
		}
		
		
		
	});
	
}


}
